package com.cynteka.cyfoman.core;

import com.cynteka.cyfoman.core.config.ActionMD;
import com.cynteka.cyfoman.core.config.ParamMD;

/**
 * User: Sergey
 * Date: 17.07.11
 * Time: 14:04
 */
public class Initializer {
    private ValueResolver resolver;

    public ValueResolver getResolver() {
        return resolver;
    }

    public void setResolver(ValueResolver resolver) {
        this.resolver = resolver;
    }

    public void init(ActionMD actionMD, ValueObject valueObject) {
        if (resolver != null) {
            for (ParamMD param : actionMD.getActionParams()) {
                String defaultValue = param.getDefaultValue();
                if (defaultValue != null) {
                    Object o = resolver.resolve(defaultValue);
                    valueObject.setParam(param, o);
                }
            }
        }
    }
}
